package com.linchong.xshop.enums;

/**
 * 店铺的状态的枚举类型
 */
public enum ShopStateEnum {
    CHENCK(0,"审核中"),
    OFFLINE(-1,"非法店铺"),
    SUCCESS(1,"操作成功"),
    PASS(2,"通过认证"),
    INNER_ERROR(10001,"系统错误"),
    NULL_SHOPID(-1002,"ShopId为空！"),
    NULL_SHOP(-1003,"Shop信息为空！");

    private int state;
    private String  stateInfo;

    /**
     * 设为私有，不希望程序外改变值
     * @param state
     * @param stateInfo
     */
    private ShopStateEnum(int state,String stateInfo){

        this.state = state; // 获得整型的状态值
        this.stateInfo = stateInfo;
    }

    /**
     * 根据传入的state返回相应的enum值
     */
    public static ShopStateEnum stateOf(int state){
        for(ShopStateEnum stateEnum:values()){
            if(stateEnum.getState()==state){
                return stateEnum;
            }
        }
        return null;
    }

    public int getState() {
        return state;
    }

    public String getStateInfo() {
        return stateInfo;
    }
}
